package com.hualan.zhsq.controller.property;

import com.hualan.zhsq.entity.property.AccessRecord;
import com.hualan.zhsq.service.property.AccessRecordService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AccessRecordController
 * @Description 访问记录controller
 * @Author ZheRan
 * @Date 2025年08月04日 下午7:54
 * @Version 1.0
 */
@RestController
public class AccessRecordController {
    @Autowired
    private AccessRecordService accessRecordService;

    //添加一条数据
    @PostMapping("/accessRecord/add")
    public Result add(AccessRecord accessRecord) {
        return Result.success(accessRecordService.add(accessRecord));
    }

    //根据id逻辑一条数据
    @DeleteMapping("/accessRecord/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        return Result.success(accessRecordService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/accessRecord/removeBatch")
    public Result removeBatch(Integer[] ids) {
        return Result.success(accessRecordService.removeBatch(ids));
    }

    //修改一条数据
    @PutMapping("/accessRecord/edit")
    public Result edit(AccessRecord accessRecord) {
        return Result.success(accessRecordService.edit(accessRecord));
    }

    //根据id查询数据
    @GetMapping("/accessRecord/findById/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(accessRecordService.findById(id));
    }

    //查询所有数据
    @GetMapping("/accessRecord/findPage")
    public Result findPage() {
        return Result.success(accessRecordService.findPage(1, 10, new AccessRecord()));
    }

}
